<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Profile_model short summary.
 *
 * Profile_model description.
 *
 * @version 1.0
 * @author xianbin
 */
class Profile_model extends CI_Model
{
    public $profile_id;
    public $title;
    public $contents;
    public $menuid;
    public $keyword;
    public $description;

    public function __construct()
    {
        parent::__construct();
        $this->load->database();
    }

    public function add_profile($profileModel)
    {
        return  $this->db->insert('profile',$profileModel);
    }

    public function get_first_row_by_menuid($menuid)
    {
        $sql="select * from profile where menuid=$menuid";
        return $this->db->query($sql)->row();
    }

    public function get_profile_by_id($profile_id)
    {
        $sql="select * from profile where profile_id=$profile_id";
        return $this->db->query($sql)->row();
    }

    public function update_profile($profileModel)
    {
        $sql="update profile set title='$profileModel->title',contents='$profileModel->contents',keyword='$profileModel->keyword',description='$profileModel->description' where profile_id=$profileModel->profile_id";
        return $this->db->query($sql);
    }

    public function del_profile($profile_id)
    {
        $sql="delete from profile where profile_id=$profile_id";
        return $this->db->query($sql);
    }
}